layui.use(['form', 'fsoft'], function () {
  var form = layui.form
    , fsoft = layui.fsoft;
  form.on('submit(login)', function (data) {
    var base = new Base64();
    var params = data.field;
    password = base.encode(params["loginPwd"]);
    params["loginPwd"] = password;
    fsoft.post(layui.cache['contentPath'] + "/sys/login", params, function (result) {
      if (result.code == 0) {
        parent.location.href = layui.cache['contentPath'] + '/index';
      } else {
        fsoft.errorMsg(result.msg);
        if ($("#captcha").val() != undefined && $("#captcha").val() != "")
          refreshCode();
      }
      return false;
    });
    return false;
  });
});

function refreshCode() {
  var captcha = document.getElementById("captcha");
  captcha.src = layui.cache['contentPath'] + "/captcha.jpg?t=" + new Date().getTime();
}